﻿using System;
using Validity.Contexts;
using Validity.Localization;
using Validity.Rules;

namespace Validity
{
  public static class IsNotEmptyConstraint
  {
    public static IConditionalValidationContext<TObject, String> IsNotEmpty<TObject>(this IValidationContext<TObject, String> context)
    {
      context.AddRule(new Rule<TObject, String>(
        (obj, val) => !String.IsNullOrEmpty(val),
        (obj, val) => RuleViolations.NotEmpty
      ));

      return new ConditionalValidationContext<TObject, String>(context);
    }
  }
}
